// JavaScript Document
function fetch_collegename(url,htno,ecode)
{

   if($("#htno").val()=='')
	{
		var html ='';
		html += "Please Enter Hallticket Number";
		$("#htmsg").html(html);
		return false;
	}
	
	if(($("#entered_captcha").val()=='') || ($("#entered_captcha").val()=='Enter the verification code'))
	{
		var html ='';
		html += "Please Enter Verification Code";
		$("#capmsg").html(html);
		return false;
	}
	
	if(($("#entered_captcha").val()!=''))
	{
		if(($("#entered_captcha").val())!=($("#code").val()))
		{
		var html ='';
		html += "Please Enter Correct Verification Code";
		$("#capmsg").html(html);
		return false;
	    }
	}
	ec = ecode.split("_");
	if(ec[0] == "pre" && ec[1] == "phd")
		fn = 'pre_phd_results';
	else
		fn = 'get_results';
		//alert("suc");
	var html ='';
	$("#capmsg").html(html);
	get_result();
	get_img();
	$.ajax({
		   type:'POST',
		   url: url+fn,
		   data: "htno="+htno+"&ecode="+ecode+"",
		   success: function(data){ //data contains JSON Object
					if(data!=0)
					{
					$("#results").html(data);
					var html='';
				    } //end of if
				else
				{  
				    var html='';
				    html += "<font color='red'>Invalid Hallticket Number</font>";
					$("#results").html(html);
				}
		   }
		   });
	get_results();
}
function get_result() {
document.getElementById('results').style.display='none';
document.getElementById('loadingImage').style.display='block';

}
function get_results() {
	document.getElementById('results').style.display='block';
document.getElementById('loadingImage').style.display='none';

}
function get_img() {
document.getElementById('forward').disabled=true;
	xmlhttp1=GetXmlHttpObject();
	if (xmlhttp1==null)	{
		alert ("Browser does not support HTTP Request");
		 return;
	}
	
				xmlhttp1.open("GET","http://jntuconnect.net/results/change_img",true)
				xmlhttp1.send(null)
	xmlhttp1.onreadystatechange=stateChanged1
}
function stateChanged1() {
	if (xmlhttp1.readyState==3||xmlhttp1.readyState==2||xmlhttp1.readyState==1||xmlhttp1.readyState==0)
	{
	
	document.getElementById("change_img").innerHTML="<img src=http://jntuconnect.net/results/images/loading.gif alt=loading/>";
	}
	if (xmlhttp1.readyState==4)
	{
	document.getElementById("change_img").innerHTML=xmlhttp1.responseText;
	document.getElementById('forward').disabled=false;
	}
}
function GetXmlHttpObject() {
	if (window.XMLHttpRequest)
	{
	 
	  return new XMLHttpRequest();
	}
	else if (window.ActiveXObject)
	  {

	  return new ActiveXObject("Microsoft.XMLHTTP");
	  }
	else {
	alert("Your browser does not support AJAX.");
	return null;
}
return null;
}

function letternumbernew2(e){
                var key;
                var keychar;
                if (window.event)
                    key = window.event.keyCode;
                else if (e)
                    key = e.which;
                else
                    return true;
	
                keychar = String.fromCharCode(key);
                keychar = keychar.toLowerCase();
            
                // control keys
                if ((key==8||key==0))
                    return true;
                else if((("0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ").indexOf(keychar) > -1)){
                	return true;
                }
                else
                    return false;
            }

  